﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace TalentDesk.Contracts.DataContracts
{
    [DataContract]
    public abstract class BaseNotifyObject : INotifyPropertyChanged
    {
        protected virtual void RaisePropertyChanged(String propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        protected virtual bool SetValue<T>(ref T target, T value, string propertyName)
        {
            if ((target != null) && (Object.Equals(target, value)))
            {
                return false;
            }

            target = value;
            RaisePropertyChanged(propertyName);
            return true;
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}
